/*
 * Currency.java
 *
 * Created on Tre?iadienis, 2006, Rugs?jo 27, 12.54
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package keitykla;

import java.io.UnsupportedEncodingException;
import java.util.Hashtable;

public class Currency 
{
    Hashtable numbers = new Hashtable();
    
    /** Creates a new instance of Currency */
    public Currency(String code,String name,String rate, String quantity, String changed, String date) 
    {
        this.code=code;
        this.name=name;
        this.rate=rate;
        this.quantity=quantity;
        this.changed=changed;
        this.date=date;
    }
    public Currency(String b)
    {
	String s;
	try
	{
            s = b;
            int idx=s.indexOf(",");
            this.code=s.substring(0,idx);
            int idx1=s.indexOf(",",idx+1);
            this.name=s.substring(idx+1,idx1);
            int idx2=s.indexOf(",",idx1+1);
            this.rate=s.substring(idx1+1,idx2);
            int idx3=s.indexOf(",",idx2+1);
            this.quantity=s.substring(idx2+1,idx3);
            int idx4=s.indexOf(",",idx3+1);
            this.changed=s.substring(idx3+1,idx4);
            this.date=s.substring(idx4+1);
	} 
        catch (Exception ex)
	{
            ex.printStackTrace();
	}
    }
    /**
     * Holds value of property code.
     */
    private String code;

    /**
     * Getter for property code.
     * @return Value of property code.
     */
    public String getCode() 
    {
        return this.code;
    }

    /**
     * Setter for property code.
     * @param code New value of property code.
     */
    public void setCode(String code) 
    {
        this.code = code;
    }

    /**
     * Holds value of property name.
     */
    private String name;

    /**
     * Getter for property name.
     * @return Value of property name.
     */
    public String getName()
    {
        return this.name;
    }

    /**
     * Setter for property name.
     * @param name New value of property name.
     */
    public void setName(String name) 
    {
        this.name = name;
    }

    /**
     * Holds value of property rate.
     */
    private String rate;

    /**
     * Getter for property rate.
     * @return Value of property rate.
     */
    public String getRate()
    {
        return this.rate;
    }

    /**
     * Setter for property rate.
     * @param rate New value of property rate.
     */
    public void setRate(String rate) 
    {
        this.rate = rate;
    }
    
    private String quantity;

    /**
     * Getter for property quantity.
     * @return Value of property rate.
     */
    public String getQuantity() 
    {
        return this.quantity;
    }

    /**
     * Setter for property quantity.
     * @param rate New value of property quantity.
     */
    public void setQuantity(String quantity) 
    {
        this.quantity = quantity;
    }
    
    private String changed;

    /**
     * Getter for property changed.
     * @return Value of property rate.
     */
    public String getChanged() 
    {
        return this.changed;
    }

    /**
     * Setter for property changed.
     * @param rate New value of property quantity.
     */
    public void setChanged(String changed) 
    {
            this.changed = changed;
    }    
    
    private String date;

    /**
     * Getter for property date.
     * @return Value of property date.
     */
    public String getDate() 
    {
        return this.date;
    }

    /**
     * Setter for property rate.
     * @param rate New value of property rate.
     */
    public void setDate(String date) 
    {
        this.date = date;
    }
    
//----------------------------------------------------------------------------------    
    
    public String getBytes()
    {
	String str= code+","+name+","+rate+","+quantity+","+changed+","+date+"|";
	return str;
    }
  
}

